package com.logic.landseaserver.common.enums;

import org.apache.commons.lang.StringUtils;

public enum LeaseCodeEnum {
    LEAS1("LEAS1", 1 ),
    LEAS2("LEAS2", 2),
    LEAS3("LEAS3", 3),
    LEAS4("LEAS4", 4),
    LEAS5("LEAS5", 5),
    LEAS6("LEAS6", 6),
    LEAS7("LEAS7", 7),
    LEAS8("LEAS8", 8),
    LEAS9("LEAS9", 9),
    LEAS10("LEAS10", 10),
    LEAS11("LEAS11", 11),
    LEAS12("LEAS12", 12 ),
    LEAS99("LEAS99", 0),
    ;

    LeaseCodeEnum(String code, Integer month) {
        this.code = code;
        this.month = month;
    }

    private String code;
    private Integer month;


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Integer getMonth() {
        return month;
    }



    public void setMonth(Integer month) {
        this.month = month;
    }

    public static Integer getMonth(String code) {

        if (StringUtils.isEmpty(code)) {
            return null;
        }
        for (LeaseCodeEnum leaseCodeEnum : LeaseCodeEnum.values()) {

            if (leaseCodeEnum.code.equals(code)) {

                return leaseCodeEnum.month;
            }
        }

        return null;
    }

    public static LeaseCodeEnum getLeaseCodeEnum(String code) {

        if (StringUtils.isEmpty(code)) {
            return null;
        }
        for (LeaseCodeEnum leaseCodeEnum : LeaseCodeEnum.values()) {

            if (leaseCodeEnum.code.equals(code)) {

                return leaseCodeEnum;
            }
        }

        return null;
    }
}
